package cn.jason.service.impl;//package cn.jason.service.impl;
//
//import cn.jason.domain.Goods;
//import cn.jason.mapper.GoodsMapper;
//import cn.jason.service.IGoodsService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//
//import java.util.Map;
//
////使用DB的排他锁  for update
//@Service
//public class GoodsServiceImpl_for_update implements IGoodsService {
//
//    @Autowired
//    private GoodsMapper goodsMapper;
//
//    @Transactional
//    @Override
//    public void updateNum(Map<String,Object> params) {
//        Long goodsId = (Long) params.get("id");
//        Integer num = (Integer) params.get("num");
//        try{
//            Goods goods = goodsMapper.laodByIdForUpdate(goodsId);
//            Thread.sleep(4000);
//            if (goods.getCount()>=num){
//                goodsMapper.updateNum(params);
//            }
//        }catch (Exception e){
//            e.printStackTrace();
//        }
//
//
//    }
//
//    @Override
//    public Goods getById(Long id) {
//        return goodsMapper.laodById(1L);
//    }
//}
